//
// Created by 原帅 on 2022/10/15.
//

#ifndef R_RACCEPTOR_H
#define R_RACCEPTOR_H

#include "RLinkInfo.h"

#define IP_STR_MAX_SIZE 32


class RAcceptor {

protected:
    int sockfd = -1;
    char ipv4str[IP_STR_MAX_SIZE] = {0};
    uint32_t ipv4 = 0;
    int port = -1;
    int type = -1;

    struct sockaddr_in serveraddr ={0};

    struct sockaddr_in clientaddr ={0};

public:
    RAcceptor(int port, int type,char *ipAddr= nullptr);

    int doListen();

    RLinkInfo doAccept();

    int getSockfd() const;

    const char *getIpv4Str() const;

    int getPort() const;
};


#endif //R_RACCEPTOR_H
